package org.tuestudent.grouppa;

import org.junit.runners.Suite;
import org.tuestudent.grouppa.*;

import java.io.UnsupportedEncodingException;

import junit.framework.Test;
import junit.framework.TestCase;

public class MCryptTest extends TestCase {

    private MCrypt instance;

    @Override
    public void setUp() throws Exception {
        instance = new MCrypt();
    }

    private void testEncryption(String text) throws Exception {

        String encrypted = instance.encrypt(text);
        String decrypted = instance.decrypt(encrypted);
        System.out.println("testing encrypt " + text + ": encrypted = "
                + encrypted + " decrypted:" + decrypted);
        assertTrue(decrypted.equals(text));
    }

    public void testEncrypt() throws Exception {
        testEncryption("bolek");

    }

    public void testEncrypt2() throws Exception {
        testEncryption("bï¿½lek");
    }


    public void testHexToBytes() throws UnsupportedEncodingException {
        System.out.println("303132 in hex:"
                + new String(MCrypt.hexToBytes("303132"), "UTF-8"));
    }

    public void testBytesToHex() {
        System.out.println("012 to bytes:"
                + MCrypt.bytesToHex("012".getBytes()));
    }

}
